﻿using MiniFox.Data.NativeClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniFox.Data.SqlServer
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public class SqlServerDataOperation<TEntity> : NativeDataOperation<TEntity> where TEntity : class
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="database"></param>
        public SqlServerDataOperation(Database database) : base(database)
        {
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="incrementParameters"></param>
        /// <returns></returns>
        protected override string CreateAutoIncrementOutputExpression(IDictionary<string, string> incrementParameters)
        {
            string sqlstr = string.Empty;
            foreach (var p in incrementParameters)
            {
                sqlstr += $"SET {p.Value}=SCOPE_IDENTITY();\r";
            }

            return sqlstr;
        }
    }
}
